#include"processbar.h"
#define FILESIZE 1024*1024*1024
void download(callback_t cb)
{
    srand(time(NULL)^23);
    int total = FILESIZE;
    while(total)
    {
        usleep(1000*10);
        int one = rand()%(10*1024*1024);
        total = total - one; // total是剩余的未被下载的内容
        if(total < 0) total = 0;

        int download = FILESIZE - total;
        double rate = ((download*1.0)/(FILESIZE))*100.0;
       //  printf("%f\n",rate);
        cb(rate);
    }
}
int main()
{
   // process();
    download(process_flush);

    return 0;
}
